package com.loocup.demo.controller;

import com.alibaba.fastjson.JSON;
import com.loocup.demo.service.DemoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @author loocup
 * @description
 * @since 2019/1/15
 */
@RestController
@Slf4j
public class DemoController {

    @Autowired
    private DemoService demoServiceImpl;

    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public String hello(@RequestParam String id, @RequestParam String name){
        log.info("in method get id = {}, name = {}", id, name);
        return "hello";
    }

    @RequestMapping(value = "/get", method = RequestMethod.GET)
    public String get(@RequestBody Map<String, Object> param){
        log.info("in method get body = {}", JSON.toJSONString(param));
        return "get success";
    }

    @RequestMapping(value = "/post", method = RequestMethod.POST)
    public String post(@RequestParam String param, @RequestParam String param2){
        log.info("in method post param = {}, param2 = {}", param, param2);
        return "get success";
    }
    @RequestMapping(value = "/json", method = RequestMethod.POST)
    public Map<String, Object> json(@RequestBody Map<String, Object> params){

        log.info("in method post body {}", JSON.toJSONString(params));
        Map<String, Object> res = new HashMap<>();
        res.put("code", 200);
        res.put("status", "SUCCESS");
        res.put("message", "成功");

        return res;
    }


//    @RequestMapping(value = "/get", method = RequestMethod.GET)
//    public TaiTou select(@RequestParam Long id){
//        return demoServiceImpl.select(id);
//    }
//
//    @RequestMapping(value = "/insert", method = RequestMethod.GET)
//    public String insert(){
//        return demoServiceImpl.insert();
//    }
//    @RequestMapping(value = "/delete", method = RequestMethod.GET)
//    public String delete(@RequestParam Long id){
//        return demoServiceImpl.delete(id);
//    }

}
